
//
//  AXFServiceFeedbackController.m
//  客服和反馈
//
//  Created by Freakthen on 2016/11/21.
//  Copyright © 2016年 Freakthen. All rights reserved.
//

#import "AXFServiceFeedbackController.h"
#import "AXFTableViewCell.h"
#import "AXFAdviceFeedbackController.h"
#import "AXFServiceOnlineController.h"
#import "AXFCommonProblemsController.h"
#import "AXFWhiteNavView.h"

NSString *cellID = @"cellID";
@interface AXFServiceFeedbackController () <UITableViewDataSource,UITableViewDelegate,AXFWhiteNavViewDelegate>

@end

@implementation AXFServiceFeedbackController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.title = @"客服／反馈";
    
    
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
}
- (void)setupUI
{
    AXFWhiteNavView *whiteNavView = [[AXFWhiteNavView alloc] init];
	
	[whiteNavView setTitleName:@"客服/反馈" andFunctionName:nil];
    
    whiteNavView.delegate = self;
    
    [self.view addSubview:whiteNavView];
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
    tableView.backgroundColor = [UIColor cz_colorWithHex:0xefefef];
    [self.view addSubview:tableView];
    tableView.dataSource = self;
    tableView.delegate = self;
    
    [tableView registerClass:[AXFTableViewCell class] forCellReuseIdentifier:cellID];
    
    [whiteNavView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.offset(0);
        make.height.mas_equalTo(kNAVBARH + 20);
    }];
    
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(whiteNavView.mas_bottom);
        make.left.right.offset(0);
        make.height.mas_equalTo(kSCREENHEIGHT - 64);
    }];
    
}

- (void)backToViewController
{
    [self.navigationController popViewControllerAnimated:YES];
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    if (section == 0) {
        tableView.rowHeight = 80;
        return 1;
    }
    else
    {
        return 3;
    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0 && indexPath.row == 0)
    {
        AXFTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath];
        cell.textLabel.text = @"在线客服";
        cell.imageView.image = [UIImage imageNamed:@"feedback_online"];
        cell.detailTextLabel.text = @"9点-24点实时回复";
        
        return cell;
        
    }
    else if (indexPath.section == 1 && indexPath.row == 0)
    {
        AXFTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath];
        
        cell.textLabel.text = @"意见反馈";
        cell.detailTextLabel.text = @"1-2个工作日内反馈";
        cell.imageView.image = [UIImage imageNamed:@"feedback_opinion"];
        return cell;
        
        
    }
    else if (indexPath.section == 1 && indexPath.row == 1)
    {
        AXFTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath];
        
        cell.textLabel.text = @"常见问题";
        cell.detailTextLabel.text = @"配送时间、优惠券和退货流程等";
        cell.imageView.image = [UIImage imageNamed:@"feedback_question"];
        
        return cell;
        
    }
    else
    {
        AXFTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath];
        
        
        cell.textLabel.text = @"客服电话";
        cell.detailTextLabel.text = @"400-8484-842";
        cell.imageView.image = [UIImage imageNamed:@"feedback_telephone"];
        
        return cell;
    }
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 15;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 5;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0 && indexPath.row == 0) {
        AXFServiceOnlineController *axfsovc = [[AXFServiceOnlineController alloc] init];
        [self.navigationController pushViewController:axfsovc animated:YES];
    }
    if (indexPath.section == 1 && indexPath.row == 0) {
        AXFAdviceFeedbackController *af = [[AXFAdviceFeedbackController alloc] init];
        [self.navigationController pushViewController:af animated:YES];
    }
    if (indexPath.section == 1 && indexPath.row == 1) {
        AXFCommonProblemsController *cp = [[AXFCommonProblemsController alloc] init];
        [self. navigationController pushViewController:cp animated:YES];
    }
    if (indexPath.section == 1 && indexPath.row == 2) {
        //        AXFServiceTelController *st = [[AXFServiceTelController alloc] init];
        //        [self.navigationController pushViewController:st animated:YES];
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"400-8484-842" message:nil preferredStyle:UIAlertControllerStyleAlert];
        [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:0 handler:^(UIAlertAction * _Nonnull action) {
            NSLog(@"YES");
        }]];
        [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
            NSLog(@"NO");
        }]];
        [self presentViewController:alert animated:YES completion:nil];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
